import { dataTableProps, PaginationProps } from 'naive-ui'
import { PropType } from 'vue'
import proComponentConfig from '../config'
import { ProTableColumns, ProTableQueryItem, ProTableRequest } from './type'
import { QueryPorps } from './type/ProTableQuery'

export const proTableProps = {
  ...dataTableProps,
  // 样式风格
  styleType: {
    type: String,
    default: proComponentConfig.proTable.stypeType,
    validator(val) {
      return ['one', 'two', 'three', 'four'].includes(val)
    }
  },
  // 搜索查询表单
  query: Array as PropType<ProTableQueryItem[]>,
  // 搜索查询配置
  queryProps: {
    type: Object as PropType<QueryPorps>,
    default: () => ({})
  },
  // 列表配置
  columns: {
    type: Array as PropType<ProTableColumns>,
    default: () => []
  },
  // 内置请求函数
  request: Function as PropType<ProTableRequest>,
  // 默认第几页
  defaultPageIndex: {
    type: Number,
    default: 1
  },
  // 默认每页大小
  defaultPageSize: {
    type: Number,
    default: 10
  },
  //无总条数查询
  noTotal: {
    type: Boolean,
    default: false
  },
  // 总条数
  total: {
    type: Number,
    default: 0
  },
  // 是否开启自适应屏幕高度
  autoHeight: {
    type: Boolean,
    default: false
  },
  // 当开启autoHeight时解决不同场景下的误差值
  relativeHeight: {
    type: Number,
    default: 0
  },
  // 当开启autoHeight时解决满屏状态下下的误差值
  fullscreenRelativeHeight: {
    type: Number,
    default: 0
  },
  // 表格的标题
  tableTitle: String,
  // 是否开启导出
  isExport: {
    type: Boolean,
    default: false
  },
  // 导出文件的文件名
  exportFilename: String,
  defaultIndexColume: {
    type: Boolean,
    default: true
  },
  // 默认序号列的宽度
  indexColumeWidth: {
    type: [Number, String],
    default: 70
  },
  // 是否显示表头的工具按钮
  tableTools: {
    type: Boolean,
    default: true
  },
  // 是否开启刷新按钮
  isRefresh: {
    type: Boolean,
    default: true
  },
  // 列的排列
  columnsAlign: {
    type: String as PropType<'left' | 'center' | 'right'>,
    default: 'center'
  },
  // 当页面开启keep-alive时，是否在onActivated回掉时重新请求列表数据
  activated: {
    type: Boolean,
    default: true
  },

  // 覆盖原始table的props
  singleLine: {
    type: Boolean,
    default: false
  },
  striped: {
    type: Boolean,
    default: true
  },
  size: {
    type: String as PropType<'small' | 'medium' | 'large'>,
    default: 'small'
  },
  pagination: {
    type: [Object, Boolean] as PropType<false | PaginationProps>,
    default: true
  }
}
